package GUI;

import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import SmartGrid.ExecutionEngine;
import Tools.Library;
import Tools.Log;

public class ConsoleInterpreter implements ActionListener{


	MainWindow main;
	
	public ConsoleInterpreter()
	{
		
	}
	
	public ConsoleInterpreter(MainWindow main)
	{
		this();
		this.main = main;
	}
	
	@Override
	public void actionPerformed(ActionEvent e) {
		String command = main.getConsole().getText();
		if(command.equals("exit"))
		{
			Log.Close();
			System.exit(0);
		}
		else if(command.equals("pause"))
			ExecutionEngine.pauseAllTasks();
		else if(command.equals("resume"))
			ExecutionEngine.resumeAllTasks();
		Library.appendToJTP(main.getStatus(), Color.BLACK, "USER: " + command + "\n");
		main.getConsole().setText("");
	}

}
